Skip to content

[codex] Preserve terminal preview link failure context#3367

Open
juliusmarminge wants to merge 2 commits into
mainfrom
codex/terminal-preview-link-errors
Open

[codex] Preserve terminal preview link failure context#3367
juliusmarminge wants to merge 2 commits into
mainfrom
codex/terminal-preview-link-errors

Conversation

@juliusmarminge

@juliusmarminge juliusmarminge commented Jun 20, 2026

Copy link
Copy Markdown
Member

Summary

  • replace swallowed terminal-link context-menu failures with a structured schema error
  • preserve complete preview command causes while retaining browser fallback behavior
  • attach environment, thread, and sanitized target-origin context without logging URL credentials or query data
  • cover both fallback boundaries with focused tests

Validation

  • vp test apps/web/src/components/preview/openTerminalLinkInPreview.test.ts
  • vp check (passes with existing warnings)
  • vp run typecheck

Note

Low Risk
Observability-only change in preview link handling with preserved fallback behavior; interrupt handling slightly changes UX by not opening the browser.

Overview
Terminal link preview no longer swallows failures when showing the context menu or opening preview. Both paths now console.error tagged Effect schema errors (TerminalLinkContextMenuShowError, TerminalLinkPreviewOpenError) that carry environmentId, threadId, the full cause, and targetOrigin derived from URL.origin so messages avoid path/query secrets.

User-facing fallback to the external browser is unchanged for real failures. Interrupted preview commands are treated differently: no error log and no browser fallback.

New unit tests cover context-menu errors, combined preview failure causes, sanitized origins, and the interrupt path.

Reviewed by Cursor Bugbot for commit 799e005. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Preserve terminal preview link failure context with structured error reporting

  • Adds two new tagged error classes, TerminalLinkContextMenuShowError and TerminalLinkPreviewOpenError, each carrying environmentId, threadId, targetOrigin (sanitized to URL origin), and the original failure cause.
  • Updates openTerminalLinkInPreview to catch context menu and preview open failures, log the appropriate structured error via console.error, and call fallbackToBrowser.
  • If the preview open failure is an interrupt (detected via isAtomCommandInterrupted), the function returns silently without logging or falling back to the browser.
  • Adds tests covering the context menu failure path, the preview open failure path, and the interrupt suppression path.

Macroscope summarized 799e005.

Co-authored-by: codex <codex@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: ba61c21b-252c-4d21-937c-4c54e61dd93b

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/terminal-preview-link-errors

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Jun 20, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Interrupt-only preview failures logged incorrectly
    • Added an isAtomCommandInterrupted guard so interrupt-only failures silently return without logging TerminalLinkPreviewOpenError or triggering the browser fallback, matching the pattern used in ChatMarkdown.tsx and other files.

Create PR

Or push these changes by commenting:

@cursor push a1e1c166b8
Preview (a1e1c166b8)
diff --git a/apps/web/src/components/preview/openTerminalLinkInPreview.ts b/apps/web/src/components/preview/openTerminalLinkInPreview.ts
--- a/apps/web/src/components/preview/openTerminalLinkInPreview.ts
+++ b/apps/web/src/components/preview/openTerminalLinkInPreview.ts
@@ -2,6 +2,8 @@
 import { isPreviewableUrl } from "@t3tools/shared/preview";
 import * as Schema from "effect/Schema";
 
+import { isAtomCommandInterrupted } from "@t3tools/client-runtime/state/runtime";
+
 import type { OpenPreviewMutation } from "~/browser/openFileInPreview";
 import { applyPreviewServerSnapshot, isPreviewSupportedInRuntime } from "~/previewStateStore";
 import { useRightPanelStore } from "~/rightPanelStore";
@@ -85,13 +87,15 @@
       input: { threadId: input.threadRef.threadId, url: input.url },
     });
     if (result._tag === "Failure") {
-      console.error(
-        new TerminalLinkPreviewOpenError({
-          ...errorContext,
-          cause: result.cause,
-        }),
-      );
-      input.fallbackToBrowser();
+      if (!isAtomCommandInterrupted(result)) {
+        console.error(
+          new TerminalLinkPreviewOpenError({
+            ...errorContext,
+            cause: result.cause,
+          }),
+        );
+        input.fallbackToBrowser();
+      }
       return;
     }
     applyPreviewServerSnapshot(input.threadRef, result.value);

You can send follow-ups to the cloud agent here.

Reviewed by Cursor Bugbot for commit a0ac289. Configure here.

Comment thread apps/web/src/components/preview/openTerminalLinkInPreview.ts
@macroscopeapp

macroscopeapp Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved

This PR adds structured error classes and logging for terminal preview link failures without changing the existing fallback behavior. The changes are purely observability improvements - errors are now logged with context (thread ID, origin) before the same fallback-to-browser path executes.

You can customize Macroscope's approvability policy. Learn more.

Co-authored-by: codex <codex@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant